//
//  ProgressCell.m
//  GoldOperationClient
//
//  Created by yaxue wang on 16/8/11.
//  Copyright © 2016年 展鸿科技. All rights reserved.
//

#import "ProgressCell.h"
#import "historyModel.h"
#import "ProgressModel.h"
@interface ProgressCell()



@end
@implementation ProgressCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
      
        UIImage *img =[UIImage imageNamed:@"Ico_progress_gray"];
        //进度点img
        _headImg=[[UIImageView alloc]initWithFrame:CGRectMake(35, 0, img.size.width,img.size.height)];
        [self addSubview:_headImg];
      
        //状态
        _stateLab=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(_headImg.frame)+14, 0, 80, 15)];
        _stateLab.font=F(14);
        _stateLab.textColor=[UIColor whiteColor];
        [self addSubview:_stateLab];
        
        //上面的一条线
        _line=[[UILabel alloc]init];
        _line.backgroundColor =[UIColor whiteColor];
        [self addSubview:_line];
        [_line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(_headImg);
            make.width.equalTo(@1);
            make.top.equalTo(_headImg.mas_bottom);
            make.bottom.equalTo(self);
        }];
        //lab
        _nameLab= [[UILabel alloc ]init];
        _nameLab.frame=CGRectMake(CGRectGetMaxX(_headImg.frame)+14, CGRectGetMaxY(_stateLab.frame)+10,WindowWidth-CGRectGetMaxX(_headImg.frame)-20, 15);
        _nameLab.font=F(14);
        _nameLab.userInteractionEnabled =YES;
        _nameLab.textColor=C(@"29b404");
        [self addSubview:_nameLab];
        //描述
        _contentLab= [[UILabel alloc ]init];
        [self addSubview:_contentLab];

        [_contentLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_headImg.mas_right).offset(14);
            make.right.equalTo(self).offset(-15);
            make.top.equalTo(_nameLab).offset(15+10);
            make.bottom.equalTo(self.mas_bottom).offset(-10);

        }];
        _contentLab.font=F(12);
        _contentLab.textColor=[UIColor whiteColor];
        _contentLab.numberOfLines=0;
        
        
        //时间
        _timeLab=[[UILabel alloc]initWithFrame:CGRectMake(WindowWidth-160, 5,150,14)];
        _timeLab.font=F(12);
        _timeLab.textAlignment =NSTextAlignmentRight;
        _timeLab.textColor=C(@"7f7e7e");
        [self addSubview:_timeLab];
       

      
    }
    return self;
}
- (void)setModel:(id)model{
    
    ProgressModel *order = model;
    NSString  *a = order.P_created;
    
    if (a ==nil||[a isEqualToString:@""]) {
        self.timeLab.text =@"";
        
    }else
    {
        self.timeLab.text =a;
    }
    if (order.P_stateNm==nil||[order.P_stateNm isEqualToString:@""]) {
        self.timeLab.text =@"";
        
    }else
    {
        _stateLab.text =order.P_stateNm;

    }
    if ([_stateLab.text isEqualToString:@"接单"]) {
        
        if ((order.P_name==nil||[order.P_name isEqualToString:@""])||(order.P_mobile==nil||[order.P_mobile isEqualToString:@""]))
        {
            _nameLab.text =@"";
            
        }else{
            
            _nameLab.text=[NSString stringWithFormat:@"%@  %@",order.P_name,order.P_mobile];
            [_nameLab bk_whenTapped:^{
                if (self.btnActionBlock) {
                    self.btnActionBlock(self);
                }
                
            }];
            
        }
        

    }
    if (order.P_content==nil||[order.P_content isEqualToString:@""])
    {
        _contentLab.text =@"";
        
    }else
    {
        _contentLab.text = order.P_content;

    }

   
}

@end
